﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using blackhouse.WebNemo.Business.Users;
using mojoPortal.Business.WebHelpers;
using mojoPortal.Web;
using mojoPortal.Business;

namespace blackhouse.WebNemo.Cms {
	public class CmsNemoUser : DecoNemoUser {

		#region Constructors

		public CmsNemoUser(INemoUser decoUser)
			: base(decoUser) { }

		#endregion

		#region Methods
		public override INemoUser GetCurrentUser() {
			SiteUser cmsUser = SiteUtils.GetCurrentSiteUser();
			if (cmsUser != null)
				return new CmsNemoUser(GetUser(4000000 + cmsUser.UserId));
			else return new CmsNemoUser(new ImpNemoUser());
		}

		public override bool HasSufficientPermissions(bool redirectToAccessDenied) {
			bool allow = WebUser.IsAdminOrContentAdminOrContentPublisherOrContentAuthor || WebUser.IsInRole("Nemo");
			if (!allow && redirectToAccessDenied)
				SiteUtils.RedirectToAccessDeniedPage();
			return allow;
		}

		#endregion

	}
}